import 'dart:ffi';

import 'package:flutter/material.dart';
import 'package:leaf_rust/bindings.dart';
import 'package:leaf_rust/leaf_rust.dart';

final DynamicLibrary dylib = DynamicLibrary.executable();
var leafLib = LeafBindings(dylib);

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    initLeaf();
  }

  void initLeaf() async{
    // LeafRust.leafRun(1, "abc.conf");
    var runBg = await LeafRust.leafRunBg(1, "abc.conf");
    print(runBg);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: const Center(
          child: Text('Hello'),
        ),
      ),
    );
  }
}
